package geppetto.cat.common;

public class GaussianDistribution extends ContinuosDistributions{

	public double mean, variance;
	public double negLogNorm;
	public GaussianDistribution(double mean, double variance){
		this.mean = mean;
		this.variance = variance;
		this.negLogNorm =  -Math.log((Math.sqrt(2*Math.PI*variance)));
	}
	
	
	public void update(double mean, double variance){
		this.mean = mean;
		this.variance = variance;
		this.negLogNorm =  -Math.log((Math.sqrt(2*Math.PI*variance)));
	}
	
	@Override
	public double getLogDensity(double x) {
		return negLogNorm -(x -mean)*(x -mean)/(2*variance);
	}

	@Override
	public double getLogDensityDerivative(double x) {
		return (mean - x)/variance;
	}

}
